<?
if (!defined('MODULE_FILE')){
die ("can't access file directly!");
}
?>
<?php require_once 'commonJS.php'; ?>
<?
require_once 'class/NewModule.php';
$att1 = new NewModule();

$mid2=$_GET['mid'];
$mid11=$_GET['mid2'];
$parent1=$_GET['parent'];

if(isset($_POST['Submit123']))
{
	
	$att1->Update();

	print "<script>";
	print "self.location='modules.php?file=list_modules&mid=$mid&smid=$smid'";		
	print "</script>";	
}

if(isset($_GET['mid2'])== true){
    $mnID = $_GET['mid2'];
    $result = $att1->get($mnID);
    
}

?>
	<div style="margin-left:20px; margin-top: 10px;">
		<p>
			<a class="btn btn-outline btn-primary btn-xs" id="active" href="modules.php?file=module_details&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >Add New Module</a>
			<a class="btn btn-outline btn-primary btn-xs" id="actie" href="modules.php?file=list_modules&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >List Of Modules</a>
		</p>
	</div>	
	
<div class="col-lg-8">
<div class="panel panel-primary">
<div class="panel-heading">Modules Details</div>
<div class="panel-body">
<div class="table-responsive">	

<form METHOD="POST" action="" id="formSubmit" name="formSubmit">

<table class="formcss" width="100%">
<tbody>
 
<tr WIDTH="100%"> 
<td valign="top">Title :</td>
<td><input type="text" name="title" id="title" class="validate[required]" size="50" value="<?php echo $result[0]['title']?>"></td>
</tr>
<tr WIDTH="100%"> 
<td valign="top">File Path:</td>
<td><input type="text" name="path" id="path" class="validate[required]" size="50" value="<?php echo $result[0]['path']?>"></td>
</tr>

<tr WIDTH="100%">
<td>Parent:</td>
<td>
<select name="parent" id="parent" class="validate[required]">
<option value="0" size="20">--SELECT--</option>
<?  
$result11 = $att1->AllList();
 $i=3;
	 //$result11=mysql_query("SELECT * FROM `menu` where parent='0' order by rank");
		 
	//while($row11 = mysql_fetch_array($result11, MYSQL_BOTH)) 
	for ($i = 0; $i < count($result11); $i++)
	{ 	
		?>
		<option  <? if($result[0]['parent']==$result11[$i]['mid']){echo "selected";} ?> value="<? echo $result11[$i]['mid']; ?>"><? echo $result11[$i]['title']; ?></option>
		<?
		 $md1=$result11[$i]['mid'];
		 $result12 = $att1->AllList2($md1);
		 //$result12=mysql_query("SELECT * FROM `menu` where parent='$md1'");
		//while($row12 = mysql_fetch_array($result12, MYSQL_BOTH))
        for ($j = 0; $j < count($result12); $j++)		
		{ 	
		
		?>
		<option <? if($result[0]['parent']==$result12[$j]['mid']){echo "selected";} ?> value="<? echo $result12[$j]['mid']; ?>"><? echo "&nbsp;&#124;&#151".$result12[$j]['title']; ?></option>
	 
	<?  }?> 
<? 	}?> 
	</select>
</td>
</tr>
<tr><td colspan="2" height="10px"></td></tr>
<tr WIDTH="100%">  
<td>Rank:</td>
<td><input type="text" name="rank" size="30" id="rank" class="validate[required]" value="<?php echo $result[0]['rank'];?>"/></td>
</tr>
<tr><td colspan="2" height="10px"></td></tr>
<tr WIDTH="100%">
<td>
<input type="hidden" name="topmid" value="<? echo $mid2;?>">
<input type="hidden" name="menuid" value="<? echo $mid11;?>">
<input type="hidden" name="hparent" value="<? echo $parent1;?>">
<input type="hidden" name="hrank" value="<?php echo $result[0]['rank'];?>">
</td>
<td align=left WIDTH="100%">
<input type="submit" name="Submit123" value="Submit">
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div>
